#!/bin/sh

export CXX=g++
export CC=gcc

export tarName="jsoncpp-1.8.4"
export libName="libjsoncpp.a"

# 如果 libjsoncpp.a 没有生成，则先编译开源库
if [ ! -f `pwd`/Lib/$libName ]; then
	tar -zxvf $tarName.tar.gz
	cd $tarName/
	mkdir Build
	cd Build
	cmake ..
	make

	# 回到解压文件根目录，查看目标文件是否已生成
	cd ..
	if [ ! -f Build/src/lib_json/$libName ]; then
		exit 1;
	fi

    # 回到压缩包所在目录,将头文件和目标文件拷贝到 Lib、Include 目录下
	cd ..
	mkdir Include Lib
    cp -rf $tarName/Build/src/lib_json/libjsoncpp.a Lib/
    cp -rf $tarName/include/json/* Include/
fi
echo $libName in Lib/
